package com.itheima.mapper;

import com.itheima.pojo.Dept;
import com.itheima.pojo.Emp;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 部门Mapper
 */
@Mapper
public interface DeptMapper {
    //@Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    void insert(Dept dept);

    void update(Dept dept);

    @Delete("delete from dept where id = #{id}")
    void deleteById(Integer id);

    @Select("select * from dept where id = #{id}")
    Dept getById(Integer id);

    @Select("select * from dept order by update_time desc")
    List<Dept> findAll();

    @Select("select * from emp where dept_id = #{deptId}")
    List<Emp> findAllEmpByDeptId(Integer deptId);
}